package ngames.com.sushitv.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import ngames.com.sushitv.R;
import ngames.com.sushitv.action.RegisterAction;
import ngames.com.sushitv.base.BaseFragment;
import ngames.com.sushitv.tools.LogUtil;

/**
 * Created by Jeffrey on 2016/8/9.
 */
public class RegisterFragment extends BaseFragment {
    public static final String BUNDLE_REGISTER_TYPE = "REGISTER_TYPE";

    public static final String REGISTER_TYPE_EMAIL = "email";
    public static final String REGISTER_TYPE_PHONE = "phone";

    private String mRegisterType;                   //email注册；phone注册
    RegisterAction mRegisterAction;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mBaseView = inflater.inflate(R.layout.fragment_register, container, false);
        return mBaseView;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Bundle bundle = getArguments();
        mRegisterType = bundle.getString(BUNDLE_REGISTER_TYPE);
        mRegisterAction = new RegisterAction(mActivity, view.findViewById(R.id.base_layout_register));
        mRegisterAction.setRegisterType(mRegisterType);
        mRegisterAction.onCreate();
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    public void destroy() {
        mRegisterAction.onDestroy();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        LogUtil.d("mFBLoginAction", "RegisterFragment-onActivityResult() requestCode = " + requestCode);
        if (mRegisterAction != null) {
            mRegisterAction.onActivityResult(requestCode, resultCode, data);
        }
    }
}
